<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 医院控制器
 */
class Hospital extends AdminBase
{
    /**
     * 获取当前用户所在的医院的健康小屋列表，并显示在页面上，供医院小屋科添加概况，维护专家团队，查看专家评价
     */
    public function healthroomList()
    {
        $hospitalid=session('department_info')['id'];
        $list=$this->logicHealthroom->getHealthroomList(['hospital_id'=>$hospitalid]);
        $this->assign('list',$list);
        return $this->fetch('healthroom_list');
    }


    /**
     * 健康小屋添加
     */
    public function healthroomAdd()
    {
        
        IS_POST && $this->jump($this->logicHealthroom->healthroomAdd($this->param));

        // if(1!=session('department_info')['type'])
        // {
        //     return [RESULT_ERROR,'当前用户非医院用户，不能增加小屋！'];
        // }

        $dlist=parse_config_array('disease_type');
        $this->assign('disease_list',$dlist);
        $this->assign('hospital_id',session('department_info')['id']);
        $this->assign('expert_list',$this->logicMember->getMemberListNew(['department_id'=>session('department_info')['id']]));
        return $this->fetch('healthroom_add');
    }
    
    /**
     * 健康小屋编辑
     */
    public function healthroomEdit()
    {
        IS_POST && $this->jump($this->logicHealthroom->healthroomEdit($this->param));
        
        $dlist=parse_config_array('disease_type');
        $this->assign('disease_list',$dlist);

        $this->assign('hospital_id',session('member_info')['hostpital_id']);
        $info = $this->logicHealthroom->getHealthroomInfo(['id' => $this->param['id']]);
        $this->assign('info', $info);
        
        return $this->fetch('healthroom_edit');
    }
    /**
     * 为健康小屋添加概况
     */
    public function introEdit()
    {
        IS_POST && $this->jump($this->logicHealthroom->introEdit($this->param));
        
        $info = $this->logicHealthroom->getHealthroomInfo(['room_id'=>$this->param['room_id']]);
        $info['description'] = html_entity_decode($info['description']);

        $this->assign('info', $info);
        return $this->fetch('intro_edit');
    }

    /**
     * 为健康小屋设置专家团队
     */
    public function expertinroomList($room_id=0,$room_name='')
    {
        $list=$this->logicExpertinroom->getExpertinroomList($room_id);
        $this->assign('list',$list);
        $this->assign('code',$room_id);
        $this->assign('name',$room_name);

        return $this->fetch('expertinroom_list');
    }

    /**
     * 为健康小屋添加专家
     */
    public function expertinroomAdd($room_id=0,$room_name='')
    {
       IS_POST && $this->jump($this->logicExpertinroom->expertinroomAdd($this->param));
       
        $where=array('department_id'=>session('department_info')['id']);
        $field='username,nickname,department_id';
        $list=$this->logicMember->getMemberListNew($where,$field);

        $this->assign('room_id',$room_id);
        $this->assign('room_name',$room_name);
        $this->assign('list',$list);
        return $this->fetch('expertinroom_add');
    }

        /**
     * 为健康小屋变更专家
     */
    public function expertinroomUpdate()
    {

    }

        /**
     * 为健康小屋删除专家
     */
        public function expertinroomDel($id=0,$room_id=0)
        {
           $this->jump($this->logicExpertinroom->expertinroomDel($id,$room_id));
        }
        /**
     * 健康小屋活动详情列表页
     */
    public function activityDetail()
    {

    }

    /**
     * 专家工作考核
     */
    public function expertEvaluation()
    {
        $list=$this->logicActivity->getHealthroomEvaluationListForHospital();
        $this->assign('list',$list);
        return $this->fetch("expert_evaluation_list");

    }

}
